var express = require("express");
var router = express.Router();
var webSettings = require("../../models/admin/webSettings.js");
webSettings = new webSettings();
//配置信息
router.post("/webSettings" , function(req , res){
	var data = {
		name:req.body.name,
		profiles:req.body.profiles
	};
	if(data.name){
		webSettings.update(data , function(error , data){
			if(error){
				return res.json({
					state:"error",
					message:error
				});
			};
			res.json({
				state:"ok",
				message:data
			});
		});
	}else{
		return res.json({
			state:"error",
			message:"请输入名称"
		})
	};
});
//获取配置信息
router.get("/webSettings" , function(req , res){
	webSettings.get(function(error , data){
		if(error){
			return res.json({
				state:"error",
				message:error
			});
		};
		return res.json({
			state:"ok",
			message:"",
			data:data[0]
		});
	});
});
//接口
module.exports = router;
